import sys


# [-5, 256]  计数非常大  除此以外都为3
# for i in range(-1000, 1000):
#     print(i, sys.getrefcount(i))


# print(sys.getrefcount(1000))
# a = 1000
# print(sys.getrefcount(1000))
# b = a
# print(sys.getrefcount(1000))
#
# l = [1000]
# print(sys.getrefcount(1000))
#
# def fun(n):
#     print(sys.getrefcount(1000))
#
# fun(b)
#
# print(sys.getrefcount(1000))
#
# l.clear()
# print(sys.getrefcount(1000))
#
# b = None
#
#
# print(sys.getrefcount(1000))
#
# a = None
# print(sys.getrefcount(1000))
#
#


a = [1]
b = [1]
print(sys.getrefcount(a), sys.getrefcount(b))
a.append(b)
b.append(a)
print(sys.getrefcount(a), sys.getrefcount(b))
# a.clear()
# b.clear()
# print(sys.getrefcount(a), sys.getrefcount(b))

# 先回收a 不行因为b使用a
# 先回收b 不行因为a使用b


